using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace teavch.Utilities.Electrical.Design.Gui.LineDiagram
{
	public partial class Reactor : ElectricalSymbol
  {

		public Reactor()
    {
      InitializeComponent();
    }

		protected override void OnPaint( PaintEventArgs e )
		{
			base.OnPaint( e );
			this.Paint( e );
		}

		protected override void OnResize( EventArgs e )
		{
			base.OnResize( e );
			ResizeNow( e );
		}

		private void ResizeNow( EventArgs ea )
		{
			this.Refresh();
		}

		private new void Paint( PaintEventArgs pea )
		{
			int _x1 = 0, _y1 = 0;
			_x1 = this.Left < 0 ? 0 : 0;
			_y1 = this.Top <= 0 ? 0 : 0;

			float _c1x1 = 0, _c1y1 = 0, _c1size = 0;
			float _c2x1 = 0, _c2y1 = 0, _c2size = 0;

			_c1x1 = _x1 - ( this.SymbolSize / 2 ) - 1;
			_c1y1 = _y1;
			_c1size = this.SymbolSize;

			_c2x1 = _x1 - ( this.SymbolSize / 2 ) - 1;
			_c2y1 = _c1size / 2;
			_c2size = this.SymbolSize;

			this.Height = ( int ) Math.Ceiling( ( _c1size + ( _c1size / 2 ) ) );
			this.Width = ( int ) Math.Ceiling( ( _c2size / 2 ) );

			System.Drawing.Drawing2D.PathGradientBrush _gBrush = null;
			System.Drawing.Drawing2D.GraphicsPath _gpath = new System.Drawing.Drawing2D.GraphicsPath();

			_gpath.AddArc( _c1x1, _c1y1, _c1size, _c1size, -90, 180 );
			_gpath.AddArc( _c2x1, _c2y1, _c2size, _c2size, -90, 180 );

			_gBrush = new System.Drawing.Drawing2D.PathGradientBrush( _gpath );
			_gBrush.CenterColor = this.Parent.BackColor;
			_gBrush.SurroundColors = new Color[] { this.State == SymbolState.On ? Color.Red : Color.Lime };

			pea.Graphics.FillPath( _gBrush, _gpath );
			pea.Graphics.DrawPath( this.Pen, _gpath );
		}

  }
}
